<?php
class b2c_ctl_admin_business_purchase extends desktop_controller{
    public function __construct($app)
    {
        parent::__construct($app);
        header("cache-control: no-store, no-cache, must-revalidate");
    }

    public function index(){

        $this->finder('b2c_mdl_business_orders_objects',array(
            'title'=>app::get('b2c')->_('供应商采购订单'),
            'use_buildin_export'=>true,//导出
            'use_buildin_recycle'=>false,
            'use_buildin_filter'=>true,
            'use_view_tab'=>true,
            'object_method'=>array('getlist'=>'get_finder_objects','count'=>'get_count')
        ));
    }

    /**
     * 供应商采购订单view 列表
     * @param null
     * @return null
     */
    public function _views(){
        $mdl_delivery = $this->app->model('business_orders_objects');
        $sub_menu = array(
            0=>array('label'=>app::get('b2c')->_('未确认采购订单'),'optional'=>false,'filter'=>array('state'=>'0')),
            1=>array('label'=>app::get('b2c')->_('已确认采购订单'),'optional'=>false,'filter'=>array('state'=>'1'))
        );

        if(isset($_GET['optional_view'])) $sub_menu[$_GET['optional_view']]['optional'] = false;

        foreach($sub_menu as $k=>$v){
            if($v['optional']==false){
                $show_menu[$k] = $v;
                if(is_array($v['filter'])){
                    $v['filter'] = array_merge(array(),$v['filter']);
                }else{
                    $v['filter'] = array();
                }
                $show_menu[$k]['filter'] = $v['filter']?$v['filter']:null;
                if($k==$_GET['view']){
                    $show_menu[$k]['newcount'] = true;
                    $show_menu[$k]['addon'] = $mdl_delivery->get_count($v['filter']);
                }
                $show_menu[$k]['href'] = 'index.php?app=b2c&ctl=admin_business_purchase&act=index&view='.($k).(isset($_GET['optional_view'])?'&optional_view='.$_GET['optional_view'].'&view_from=dashboard':'');
            }elseif(($_GET['view_from']=='dashboard')&&$k==$_GET['view']){
                $show_menu[$k] = $v;
            }
        }
        return $show_menu;
    }



}